

package commandz.cli;

import java.util.Collection;


/**
 *  Decorates a Command with a different name and description.
 *
 *  This class can be used to create a pseudonym for a existing command.
 */
public class Alias implements Command
{
    protected String name;
    protected Command command;


    /**
     *  Initializes a new instance for use with the given identifier and command.
     *
     *  @param identifier A unique identifier, not equal to the name of the
     *                    target-command, to use as a pseudonym.
     *  @param target     The actual command.
     */
    public Alias(final String identifier, final Command target)
    {
        this.name = identifier;
        this.command = target;
    }


    public String getName()
    {
        return this.name;
    }


    public String getDescription()
    {
        return String.format("Alias for \"%s\".", this.command.getName());
    }


    public void publishParameters(Collection<Parameter> params)
    {
        this.command.publishParameters(params);
    }


    public void execute()
    {
        this.command.execute();
    }
}
